package migrations

import (
	"github.com/goravel/framework/contracts/database/schema"
	"github.com/goravel/framework/facades"
)

type M20250224103849CreateMenusTable struct {
}

// Signature The unique signature for the migration.
func (r *M20250224103849CreateMenusTable) Signature() string {
	return "20250224103849_create_menus_table"
}

// Up Run the migrations.
func (r *M20250224103849CreateMenusTable) Up() error {
	if !facades.Schema().HasTable("menus") {
		return facades.Schema().Create("menus", func(table schema.Blueprint) {
			table.ID()
			table.UnsignedBigInteger("parentId")
			table.String("path")
			table.String("component")
			table.String("name")
			table.Json("meta")
			table.String("redirect")
			table.Unique("path")
			table.Unique("name")
			table.Timestamps()
			table.SoftDeletes("deleted_at")

		})
	}

	return nil
}

// Down Reverse the migrations.
func (r *M20250224103849CreateMenusTable) Down() error {
	return facades.Schema().DropIfExists("menus")
}
